{% extends "school/layout.html" %}

{% set page_title = translate('学生点评') %}

{% block content %}
<div class="m-teacher-list">
<div class="m-fixed-table-top">
	<div class="title">
		<div class="name handle_nav">
			<a href="{{ url_for('school.teacher_comment_list') }}" class="active">待处理评价</a>
			<a href="{{ url_for('school.sent_teacher_comment_list') }}">已处理评价</a>
		</div>
		<!-- <div class="search" style="display:inline-block;"> -->
		<div class="search" style="display:none;">
			<input type="text" class="form-control" placeholder="姓名">
			<input type="text" class="form-control" placeholder="日期yyyy-mm-dd" id="search_date">
			<a class="btn btn-default" style="vertical-align:top;">查找</a>
		</div>
		<!-- <p class="text">待点评数量：{{ pagination.total }}个</p> -->
	</div>
</div>
<ul class="comments m-ul-table">
	<li class="header">
		<span class="cell name">姓名</span>
		<span class="cell class_time">上课时间</span>
		<span class="cell pingfen">系统评分</span>
		<span class="cell teacher_evaluate">教师评价</span>
		<span class="cell handle">操作</span>
	</li>
	{% for c in teacher_comments %}
	<li class="row-li" id="comments_{{ c.id }}">
		<span class="cell name">{{ c.student.name }}</span>
		<span class="cell class_time">{{ c.session.start_at }} - {{ c.session.end_at }}</span>
		<span class="cell pingfen">{{ c.system_score | round(1) | replace('.0', '') }}</span>
		<span class="cell teacher_evaluate">
			<input id="comment_{{ c.id }}" type="text" placeholder="评语" maxlength="70" />
			<input id="score_{{ c.id }}" type="text" placeholder="评分" maxlength="3" />
		</span>
		<span class="cell handle">
			<input class="btn_submit" id="submit_{{ c.id }}" type="button" value="提交" data-url="{{ url_for('school.teacher_comment', comment_id=c.id) }}" />
			<input class="btn_abort" id="abort_{{ c.id }}" type="button" value="不评价" data-url="{{ url_for('school.teacher_comment', comment_id=c.id) }}" />
		</span>
	</li>
	{% endfor %}
	<li class="row-li">
		<span class="cell name">阿May五四三二一</span>
		<span class="cell class_time">2016-02-19 16:57:10 - 2016-02-19 17:00:33</span>
		<span class="cell pingfen">0</span>
		<span class="cell teacher_evaluate">
			<input type="text" maxlength="70" placeholder="评语">
			<input type="text" maxlength="3" placeholder="评分">
		</span>
		<span class="cell handle">
			<button>评价</button>
			<button>不评价</button>
		</span>
	</li>
</ul>


{% include "school/pagination.html" %}
</div>
<!--点击删除时的弹框-->
<div class="modal">
	<div class="modal-dialog modal-sm">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title">确定不评价吗？</h4>
			</div>
			<div class="modal-body">
				<button class="btn btn-danger">确定</button>
				<button class="btn btn-default">取消</button>
			</div>
		</div>
	</div>
</div>

{% endblock %}

{% block js %}
<script type="text/javascript">
	$(function(){
		$('.modal-body button').bind('click',function(){
			$('div.modal').modal('hide');
		});
	});

	function ajaxCallback(data) {
		if (data == 'OK') {
			window.location.reload();
		} else {
			alert(data);
		}
	}

	$('.btn_submit').click(function () {
		var id = $(this).attr('id').split('_')[1];
		var comment = $('#comment_' + id).val();
		var score = $('#score_' + id).val();
		var msg = '确定推送评价：“' + comment +'”？';
		if (confirm(msg)) {
			$.post($(this).data('url'), {contents: comment, teacher_score: score, action:'send'}, ajaxCallback);
		}
	});

	$('.btn_abort').click(function () {
		var id = $(this).attr('id').split('_')[1];
		if (confirm('确定要放弃评价吗？')) {
			$.post($(this).data('url'), {action:'abort'}, ajaxCallback);
		}
	});

	$('#search_date').datetimepicker({
		format:'yyyy-mm-dd',
		autoclose:true,
		todayBtn:true,
		minView:2,
		language: 'zh-CN'
	});
	$('.handle_nav').delegate('a','click',function(){
		$('.handle_nav a').removeClass('active');
		$(this).addClass('active');
	});
</script>
{% endblock %}
